package com.sino.bucket;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@ConditionalOnProperty("bucket.rate")
@Import(BucketProperties.class)
public class BucketConfiguration {

    @Bean
    public LeakyBucketHandle defaultBucketCreate(BucketProperties bucketProperties) {
        return new LeakyBucketHandle(bucketProperties.getRate(), bucketProperties.getCapacity());
    }
}
